<template>
  <div class="box">
    <van-nav-bar class="top" fixed placeholder title="网易严选">
      <template #left>
        <van-icon
          style="margin-left: 50px"
          color="#666"
          name="wap-home-o"
          size="20"
          @click="goto('/home')"
        />
      </template>
      <template #right>
        <van-icon
          style="margin-right: 10px"
          color="#666"
          name="search"
          size="20"
          @click="goto('/search')"
        />
        <van-icon
          style="margin-right: 50px"
          color="#666"
          name="shopping-cart-o"
          size="20"
          @click="goto('/cart')"
        />
      </template>
    </van-nav-bar>
    <div class="content">
      <div class="con">
        <div class="bag">
          <span>包裹</span>
          <span class="fu">已付款</span>
        </div>
        <div class="boxx">
          <div class="baoguo"  v-for="item in data" :key="item.goods_id">
            <div class="ding">
              <van-card
                :num="item.cart_num"
                :price="item.goods_price"
                :thumb="item.goods_small_logo"
              >
                <template #title class="van-multi-ellipsis--l2">
                  {{ item.goods_name }}
                </template>
              </van-card>
            </div>
          </div>
          <div class="bian">
            <div class="hao">订单编号:<span>16215616541</span></div>
            <van-divider
              :style="{
                color: '#1989fa',
                borderColor: '#ccc',
                padding: '0 10px',
              }"
            >
            </van-divider>
            <div class="tiao">
              <div class="ti1">
                <img src="../assets/home/tiaoxing.png" alt="" />
                <span>条形码</span>
              </div>
              <van-icon name="arrow" />
            </div>
          </div>
          <div class="total">
            <div class="heji">商品合计：￥{{totalPrice}}</div>
            <div class="you">邮费：￥0.00</div>
            <van-divider
              :style="{
                color: '#1989fa',
                borderColor: '#ccc',
                padding: '0 16px',
              }"
            >
            </van-divider>
            <div class="ying">合计：￥{{totalPrice}}</div>
            <div class="que">
              <div>确认收货得<span>124</span>积分</div>
              <div class="haoli">
                <div>积分兑好礼</div>
                <van-icon name="arrow" />
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "unpain",
  data() {
    return {
      data: [],
    };
  },
  created() {
    const { id } = this.$route.params;
    this.getdetails(id);
  },
  computed:{
    totalPrice(){
          return this.data.reduce((val,item)=>{
            return val+item.total
          },0)
        }
  },
  methods: {
    goto(url) {
      this.$router.push(url);
    },
    async getdetails(id) {
      const { data } = await this.$request.get("/api/orders/od/" + id);
      this.data = data.data;
    },
   
  },
};
</script>
<style scoped lang="scss">
.box {
  .content {
    .con {
      padding: 20px;
      background: #f5f5f5;
      .to {
        padding: 14px;
        background-color: #fffced;
        .xinxi {
          display: flex;
          justify-content: flex-start;
          align-items: center;
          .chen {
            display: inline-block;
            margin-right: 20px;
          }
          .van-button {
            background-color: #fffced;
            margin-left: 140px;
          }
        }
        .dizhi {
          color: #7f7f7f;
          text-align: left;
        }
      }
      .bag {
        display: flex;
        justify-content: space-between;
        height: 45px;
        line-height: 30px;
        padding: 10px 15px 10px 15px;
        background-color: #fff;
        border-bottom: 1px solid #ccc;
        box-sizing: border-box;
        .fu {
          color: #dd1a21;
        }
      }
      .baoguo {
        background-color: #fff;
        padding: 15px;

        .van-card__content {
          text-align: left;
        }
      }
      .bian {
        background-color: #fff;
        margin-top: 15px;
        text-align: left;
        padding: 15px;
        .hao {
          font-size: 14px;
          color: #7f7f7f;
          span {
            color: black;
            margin-left: 10px;
          }
        }
        .tiao {
          width: 100%;
          display: flex;
          justify-content: space-between;
          .ti1 {
            img {
              width: 28px;
              height: 17px;
              vertical-align: middle;
              margin-right: 5px;
            }
            span {
              color: #333;
              font-size: 14px;
              line-height: 14px;
              vertical-align: middle;
            }
          }
        }
      }
      .total {
        margin-top: 10px;
        background-color: #fff;
        text-align: left;
        padding: 15px;
        color: #666;
        .you {
          margin-top: 3px;
        }
        .ying {
          font-size: 14px;
          color: #dd1a21;
        }
        .que {
          display: flex;
          justify-content: space-between;
          align-items: center;
          margin-top: 5px;
          background-color: #fffced;
          height: 35px;
          .haoli {
            display: flex;
            align-items: center;
            .van-icon {
              padding-top: 2px;
            }
          }
        }
      }
    }
  }
}
</style>
